<template>
    <div class="media">
        <InfoTop :hdBgUrl="bgImage" infoTopTitle="媒体报道" infoTopEnglish="MEDIA REPORT"></InfoTop>
        <div class="mediaContent">
            <ul>
                <li v-for="item in medias" :key="item.id">
                    <router-link :to="`mediadetail/${item.id}`">
                        <h3>{{ item.date }}<i></i><font>{{ item.month }}月</font></h3>
                        <p v-text="item.title"></p>
                        <img src="../../../assets/images/new.png" alt="" v-if="item.new === 1">
                        <span v-text="`>`"></span>
                    </router-link>
                </li>
            </ul>
            <el-pagination
                background
                layout="prev, pager, next"
                :total="length"
                :prev-text="`<上一页`"
                :next-text="`下一页>`"
                @current-change="handleCurrentChange"
                :current-page="currentPage">
            </el-pagination>
        </div>
    </div>
</template>

<script>
    import InfoTop from '../include/InfoTop.vue';
    // myData[i].new 0->show new 1->hide new
    let myData = [
        {
            id: 1,
            date: 30,
            month: 11,
            title: '【放假通知】钱内助国庆节、中秋节放假通知',
            new: 1
        },
        {
            id: 2,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 3,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 4,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 5,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 6,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 7,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 8,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 9,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        },
        {
            id: 10,
            date: 15,
            month: 11,
            title: '【系统升级】钱内助系统升级通知',
            new: 0
        }
    ];
    function empty(){
        myData.splice(0, myData.length);
    }
    function setMyData(index){
        for(let i = 0; i < 10; i ++){
            myData.push(aaa[i + (index - 1) * 10]);
        }
    }
    export default{
        data(){
            return{
                bgImage: require('../../../assets/images/newsbg.png'),
                currentPage: 1,
                medias: myData,
                length: myData.length
            }
        },
        components: {
            InfoTop
        },
        methods: {
            handleCurrentChange(val){
                this.currentPage = val;
                console.log(this.currentPage);
                empty();
                //setMyData(val);
            }
        }
    }
</script>

<style lang="scss" scoped>
    .media{
        width: 920px;
        margin-bottom: 50px;
    }
    .mediaContent{
        width: 920px;
        background: #ffffff;
        ul{
            min-height: 1130px;
        }
        li{
            width: 820px;
            height: 112px;
            border-bottom: 1px solid #dfdfdf;
            margin: 0 auto;
            position: relative;
            a{
                display: block;
                width: 100%;
                height: 100%;
                outline:0;-webkit-tap-highlight-color:rgba(255,0,0,0);-webkit-appearance:none;text-decoration:none;list-style-type: none;
                h3{
                    display: inline-block;
                    font-size: 28px;
                    line-height: 100px;
                    position: absolute;
                    color: #333333;
                    font{
                        font-size: 16px;
                        position: relative;
                        top: 15px;
                        left: 10px;
                    }
                    i{
                        display: inline-block;
                        height: 70px;
                        width: 1px;
                        background: #e1e1e1;
                        position: absolute;
                        transform: rotate(25deg);
                        top: 25px;
                        left: 40px;
                    }
                }
                p{
                    display: inline-block;
                    line-height: 112px;
                    font-size: 20px;
                    margin: 0 0 0 120px;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    width: 630px;
                    color: #333333;
                }
                span{
                    font-size: 20px;
                    color: #cbcbcb;
                    position: absolute;
                    right: 0;
                    top: 42px;
                }
                img{
                    margin: 0 0 47px 0;
                }
            }
            
    }
    }
    
</style>

<style>
    .el-pagination{
        text-align: center;
    }
    .el-pagination.is-background .el-pager li{
        min-width: 35px;
        height: 35px;
        text-align: center;
        line-height: 35px;
        border: 1px solid #e8e8e8;
        border-radius: 4px;
        margin: 48px 2px 64px 2px;
    }
    .el-pagination.is-background .el-pager li.active{
        border: 1px solid #ee7550;
        color: #ee7550;
        background: #fdf5ef;
    }
    .el-pagination.is-background .el-pager li:hover{
        color: #ee7550;
    }
    .el-pagination.is-background .btn-next, .el-pagination.is-background .btn-prev{
        height: 35px;
        margin: 48px 2px 64px 2px;
        padding: 0 6px;
    }
</style>
